enum Role {
  Admin = "admin",
  User = "user",
}

const withRole = (role: Role) => (component: React.FC) => {
  const hasRole = role === Role.Admin;

  if (hasRole) {
    return component;
  } else {
    return <div>没有权限</div>;
  }
};

const adminComponent = () => <div>admin component</div>;

const userComponent = () => <div>user component</div>;

const AdminComponent = withRole(Role.Admin)(adminComponent);
const UserComponent = withRole(Role.User)(userComponent);

export { AdminComponent, UserComponent };
